<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/content/variable.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<%@ include file="/content/head.jsp"%>
</head>
<body>
    <div class="row">
        <div class="col-md-12">
            <div class="box box-info">
                <div class="box-header with-border">
                    <h3 class="box-title">修改秘约内容</h3>
                </div>
                <form id="editInfo" class="form-horizontal" role="form" onsubmit="javascript:saveInfo();">
                    <div class="box-body">
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">名字：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="name" class="form-control" name="name" value="${obj.name}"
                                       placeholder="名字">
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="weChat" class="col-sm-2 control-label">微信：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="weChat" class="form-control" name="weChat" value="${obj.weChat}"
                                       placeholder="微信">
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="seeNumber" class="col-sm-2 control-label">查看人数：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="seeNumber" class="form-control" name="seeNumber" value="${obj.seeNumber}"
                                       placeholder="查看人数">
                            </div>
                        </div>
                        <br>

                        <div class="form-group">
                            <label for="city" class="col-sm-2 control-label">城市：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="city" class="form-control" name="city" value="${obj.city}"
                                       placeholder="城市">
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="tags" class="col-sm-2 control-label">标签(多个以","分割)：</label>
                            <div class="col-sm-8 ">
                                <input type="text" id="tags" class="form-control" name="tags" value="${obj.tags}"
                                       placeholder="标签">
                            </div>
                        </div>
                        <br>
                        <div class="form-group">
                            <label for="avatar" class="col-sm-2 control-label">封面：</label>
                            <div class="col-md-8">
								<input type="file" class="file-loading" id="avatarImgFile" accept="image/*">
								<input type="text" class="form-control input-sm" id="avatarImgUrl" name="avatar" value="${obj.avatar}"> 
							</div>
							<div class="col-sm-2">
								<span class="help-inline" style="color: #a94442"></span>
							</div>
                        </div>
                        <br>
                         <input type="hidden" name ="id" id="id" value="${obj.id}"/>
                        <div class="col-md-offset-5 col-md-9">
                            <button type="submit" class="btn btn-success">确定</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <!-- /.row -->
	
<%@ include file="/content/js.jsp"%>
<script type="text/javascript">
$(function(){
//封面上传
   $("#avatarImgFile").fileinput({
   	uploadUrl:"<%=path%>/appointment/uploadClassifyImg",
       browseClass: "btn btn-primary",
       enctype: 'multipart/form-data',
       autoReplace:true,
       dropZoneEnabled:false,
       browseLabel: "上传",
       showCaption: false,
       showRemove: false,
       showUpload: true,
       showZoom:false,
       maxFileCount:1, ////表示允许同时上传的最大文件个数
       allowedFileTypes:["image"], //文件的选择类型[‘image’, ‘html’, ‘text’, ‘video’, ‘audio’, ‘flash’, ‘object’]
       previewSettings:{
       	image: {width: "auto", height: "100px"},
       },
   });
   $('#avatarImgFile').on('fileuploaded', function(event, data, previewId, index) {
   	var path = data.response.initialPreviewConfig[0].extra.path;
       $("#avatarImgUrl").val(path);
   });
   $('#avatarImgFile').on('filedeleted', function(event,key,jqXHR,data) {
   	if($("#avatarImgUrl").val()==data.path)
   		$("#avatarImgUrl").val('');
   }); 
});

	function saveInfo(){
		var weChat = $("#weChat").val();
		var seeNumber = $("#seeNumber").val();
		var avatar = $("#avatarImgUrl").val();
		var tags = $("#tags").val();
		var city = $("#city").val();
		var name = $("#name").val();
		var id =$("#id").val();
		$.ajax({
			type:"post",
			async: false,
			url:"<%=path%>/appointment/alertAppointmentSave",
			data:{id:id,
				name:name,
				weChat:weChat,
				seeNumber:seeNumber,
				avatar:avatar,
				tags:tags,
				city:city,},
			dataType:"json",
			success: function(data){
				if (data.missage == "success") {
                    modalMsg("修改成功", "success");
                    window.parent.location.reload();
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }else if(data.missage == "error"){
                	 modalMsg("修改失败", "error");
                }else{
                	 modalMsg("更新失败", "error");
                }
			}
		});
	}
</script>
</body>
</html>